package it.unibo.mycruise.boat;

import java.util.List;
import java.util.Observable;
import java.util.concurrent.CopyOnWriteArrayList;

import it.unibo.convoycruisecontrol.boatsubsystem.IDashboard;
import it.unibo.location.ILocation;

/**
 * @author ale
 * @version 1.0
 * @created 24-ott-2012 00:48:19
 */
public class Dashboard extends Observable implements IDashboard {

	private float distanceCovered;
	private List<ILocation> locations;
	private float currentSpeed;

	public Dashboard(){
		this.distanceCovered = 0;
		this.locations = new CopyOnWriteArrayList<ILocation>();
		this.currentSpeed = 0;
	}

	public float getDisplayedDistanceCovered(){
		return distanceCovered;
	}

	public List<ILocation> getDisplayedLocations(){
		return locations;
	}

	public float getDisplayedCurrentSpeed(){
		return currentSpeed;
	}

	/**
	 * 
	 * @param speed
	 */
	public void updateCurrentSpeed(float speed){
		this.currentSpeed = speed;
		setChanged();
		notifyObservers();
	}

	/**
	 * 
	 * @param distance
	 */
	public void updateDistanceCovered(float distance){
		this.distanceCovered = distance;
		setChanged();
		notifyObservers();
	}

	/**
	 * 
	 * @param locations
	 */
	public void updateMap(List<ILocation> locations){
		//pulisci lista
		this.locations.clear();

		//ripopola lista
		for (ILocation location : locations) {
			this.locations.add(location);
		}
		setChanged();
		notifyObservers();
	}
}